package com.onion.codegen.gen;

import java.util.List;

import com.onion.codegen.bean.DbTableProperties;
import com.onion.codegen.bean.JavaBeanProperties;
import com.onion.codegen.bean.GeneratorProperties;
import com.onion.codegen.utils.DbMetaDataUtil;
import com.onion.codegen.utils.TableToJavaEntityUtil;

/**
 * @author yangsong
 *
 */
public abstract class BaseGenerator {

	private GeneratorProperties javaEntityProperties;

	public void initAndGenClass() throws Exception {
		DbMetaDataUtil.setDbProperties(javaEntityProperties.getDbProperties());
		List<DbTableProperties> tablePropertiesList = DbMetaDataUtil.initTablePropertie(javaEntityProperties.getGenTables());
		List<JavaBeanProperties> tableToJava = TableToJavaEntityUtil.tableChangeToJava(tablePropertiesList, javaEntityProperties);
		genJavaClasss(tableToJava, javaEntityProperties);
	}
	
	public abstract void genJavaClasss(List<JavaBeanProperties> javaPropertiesList,GeneratorProperties javaEntityProperties) throws Exception;

	public GeneratorProperties getJavaEntityProperties() {
		return javaEntityProperties;
	}

	public void setJavaEntityProperties(GeneratorProperties javaEntityProperties) {
		this.javaEntityProperties = javaEntityProperties;
	}

	
}
